<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>选择部位</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="医疗问诊,智能问诊,问诊">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./css/wx.css" />
<link rel="stylesheet" href="./css/weui.css" />
<link rel="stylesheet" href="./css/example.css" />
<link rel="stylesheet" href="./js/bootstrap-3.3.5-dist/css/bootstrap.min.css" />
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/bootstrap-3.3.5-dist/js/bootstrap.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-all.min.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script src="./js/bootstrap-jquery-plugin/jquery.bootstrap.js"></script>
<script src="./js/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/wx.js"></script>
<script type="text/javascript" src="./js/zepto.min.js"></script>
<script type="text/javascript" src="./js/example.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<style type="text/css">
ul li{
	border-bottom:1px solid #efefef;
	border-right: 1px solid #efefef;
}
ul li a:link{ 
	text-decoration:none; 
} 
ul li a:visited{ 
	text-decoration:none; 
} 
ul li a:hover{ 
	text-decoration:none; 
} 
ul li a:active{ 
	text-decoration:none; 
}

ul li ul li{
	border-top:0px solid #efefef;
	border-right: 1px solid #efefef;
	text-align: left;
	margin-left: 10%;
}
ul li ul li a{
	color:#000;
	text-align: left;
}
 
.isActive{
	border-bottom: 1px solid #efefef;
	border-right: none;
}

.isActive a{
	color : #337ab7;
}

.text-color{
	color : #777;
    font-size: 16px;
}

.container ul li{
	list-style:none; /* 将默认的列表符号去掉 */
	padding:0; /* 将默认的内边距去掉 */
	margin:5px; /* 将默认的外边距去掉 */
	float:left; /* 往左浮动 */
	border-radius:10px;
}
.container ul li a{
	display:block; /* 将链接设为块级元素 */
	width:auto; /* 设置宽度 */
	height:40px; /* 设置高度 */
	line-height:30px; /* 设置行高，将行高和高度设置同一个值，可以让单行文本垂直居中 */
	text-align:center; /* 居中对齐文字 */
	color:#000; /* 设置文字颜色 */
	text-decoration:none; /* 去掉下划线 */
	padding-left: 15px;
	padding-right: 15px;
	padding-top: 5px;
}
.isSelect {
	background-color:#efefef;
	background-image: url(./images/click.png) !important;
	background-repeat: no-repeat;
    background-position: right bottom !important;
	color: #23598A;
	border-radius:5px;
}
footer{
	position:fixed ;
	bottom: 0;
	width: 100%
}
footer ul{
	margin-bottom :0
}
footer ul li {
	height: 40px;
	background-color: #efefef;
	color: #fff
}
footer ul li p{
	position:absolute;
	margin-top: -11px;
	margin-left: 42%
}
.btn-select{
	background-color: #337ab7;
}
table{ 
	table-layout:fixed; 
	empty-cells:show; 
	border-collapse: collapse; 
	margin:0 auto; 
	width: 98%;
	height: 300px;
} 
td{ 
	height:30px; 
	text-align: center;
	padding: 10px;
	border-radius:5px;
	margin-right: 5px;
} 

.tr-border-left{
	border-bottom: 1px solid #efefef;
	border-right: 1px solid #efefef;
	border-top: 1px solid #efefef;
}

.tr-border-right{
	border-bottom: 1px solid #efefef;
	border-left: 1px solid #efefef;
	border-top: 1px solid #efefef;
}

.tr-border-bottom{
	border-bottom: 1px solid #efefef;
}

table tbody tr {
    display:table;
    width:100%;
    table-layout:fixed;
}
#optTip{
text-align: center;
color: blue;
font-size: 15px;
}
.text-gradient {
    display: inline-block;
    color: red;
    font-size: 20px;
    ont-family: ´微软雅黑´;
    background-image: -webkit-gradient(linear, 0 0, 0 bottom, from(rgb(41, 7, 226)), to(rgb(247, 24, 24)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.img_border{
	border: 1px solid red;
}
.input_style{
	border:none !important;
	background-color: #efefef;
	width:80%;display: inline !important;
}
.change_role{
	vertical-align: initial !important;
	padding:1px !important;
	color: rgba(247, 47, 2, 0.5);
	width: 18%;
}
</style>
<script type="text/javascript">

var storage = window.localStorage;
var ageFlag;
var currSexflag;
var partArr = [];
//当前选择部位
var onOnePart;
//当前选择二级病症
var onTwoPart='';
var twoPartFlag = false;
//当前的疾病ids
var ids = [];
//当前选择的病症
var symptom;
var symptomFlag = false;
var secondSymptomFlag = false;
var usedSymptoms = [];
var usedParts = [];
var curr_img_select_arr = [];

//病历拼接
var symptomsArr = '';

//搜索模式
var findMod = false;
var currPart = '常见症状';
var sexAndAgeFlag = false;

$(document).ready(function() {
	console.log("primaryRole="+storage.getItem("primaryRole")+"&currentName="+storage.getItem("currentName")+"&currentRole="+storage.getItem("currentRole")+"&isMainRole="+storage.getItem("isMainRole"));
	console.log("curSex="+storage.getItem("curSex")+"&curage="+storage.getItem("curage")+"&curAgeFlag="+storage.getItem("curAgeFlag"));
	
	$("#optTip").html("<请选择<span class='text-gradient'>最</span>不舒服的症状>");
	var username = storage.getItem("currentName");
	if(username=="" || username==null){
	   var url="./jsp/login.jsp?iswx=1";
	   window.location.href = url;
   	}
   	$("#my_role").html(getfrontThreeChar(username));
   	storage.setItem("username", username);
   	
   	getIllnessBySexAndAge();
   	
	//点击一级部位事件
	$("#partmenu_con ul.first").on("click","li",function() {
		$(this).parent().find('li').each(function(){
			if($(this).hasClass("isActive")){
				$(this).find('li').each(function(){
					$(this).toggle();
				});
				$(this).removeClass("isActive");
			}
		});
		
		var part = $(this).text();
		if(part=="常见症状"){
			$("#optTip").html("<请选择<span class='text-gradient'>最</span>不舒服的症状>");
			getCommonSymp();
			currPart = '常见症状';
			$("#symp_input").val('');
		}else if(part=="搜索症状"){
			$("#optTip").html("<请选择<span class='text-gradient'>最</span>不舒服的症状>");
			currPart = '搜索症状';
		}else{
			currPart = '其它';
			$("#optTip").html("<请选择<span class='text-gradient'>最</span>不舒服的部位>");
			$("#symp_input").val('');
		}
		onOnePart = part;
		$(this).addClass("isActive");
		
		var table = document.getElementById("table");
		while(table.hasChildNodes())
	    {
	        table.removeChild(table.firstChild);
	    }

		for(var i=0;i<partArr.length;i++){
			var pArr = partArr[i];
			if(pArr.onePart==part){
				$("#table").html('');
				for(var j=0;j<pArr.arr.length;j++){
					
					var table = document.getElementById("table");
					var tr = document.createElement("tr");
					var part1 = pArr.arr[j];
					var part2 = pArr.arr[++j];
					if(part2){
						tr.innerHTML = '<td id="p'+part1+'" onclick="show(\''+part1+'\')">'+part1
										+'</td><td id="p'+part2+'" onclick="show(\''+part2+'\')">'+part2+'</td>'; //向li内添加文本
					}else{
						tr.innerHTML = '<td id="p'+part1+'" onclick="show(\''+part1+'\')">'+part1+'</td><td id=""></td>'; //向li内添加文本
					}
					table.appendChild(tr);
				}
			}
		}
	});
	
});

    function commit(){
    	var w_height = $(window).height();
    	var val = $("input[name='radio100']:checked").val();
    	if(val==storage.getItem("primaryRole")){//如果选择的和主用户一样
    		storage.setItem("currentRole",val);
    		storage.setItem("isMainRole",1);
    	}else{
    		storage.setItem("currentRole",val);
    		storage.setItem("isMainRole",0);
    	}
    	$.ajax({
           	url: "./user/currRole",
           	type: "POST",
           	data:{
           		currRole : val,
				isMainRole : storage.getItem("isMainRole")          		
           	},
           	dataType: 'json',
           	cache: false,
           	success: function (ret) {
             	if (ret.resultCode==0) {
           	   	  $('.theleftmenu').css('height',w_height);
           	      $('.theleftmenu .theleftmenu_con ').stop().animate({ left: '-100%' }, 400);
           	      setTimeout(function(){
           	          $('.theleftmenu,.bg_mark').fadeOut('fast');
           	      },200);
           	      var now = getSmpFormatNowDate(false);
           	      /* alert(now); */
           	      var birth = getSmpFormatDateByLong(ret.content.birth,false);
           	      /* alert(birth); */
           	      /* var age = DateDiff(now,birth);//多少天  */
           	      var age = ret.content.day;
           	      /* alert(age); */
           	      var sex = ret.content.sex;
           	      storage.setItem("curSex",sex);
           	      storage.setItem("curage",age);
           	      storage.setItem("currentName",ret.content.userName);
           	      $("#my_role").html(getfrontThreeChar(ret.content.userName));
           	      console.log("curage=年龄是=="+age);
           	      console.log("性別===="+sex);
           	      
				  ageFlag = dayToAgeFlag(age);
            	  storage.setItem("curAgeFlag",ageFlag); 
            	  console.log("ageFlag=年龄是=="+ageFlag);
            	  //按年龄和性别获取疾病ids
				  getIllnessBySexAndAge();
              }
           }
       });
    }
    
    function getfrontThreeChar(str){
    	if(str.length>3){
    		return str.substr(0, 3);
    	}else{
    		return str;
    	}
    }

	//完成选择事件，判断是否有选择病症
	function toAsk(){
		if(!$("#btn").hasClass("btn-select")){
			return;
		}
		var obj= document.getElementById("table");
		var tr= obj.getElementsByTagName("tr");
		if(tr.length==0) {
			alert("无");
			return;
		}
		
		if(currPart=='常见症状' || currPart=='搜索症状'){
			findMod = true;
			symptomFlag = false;
		}else{
			findMod = false;
			symptomFlag = true;
		}
		
		if(findMod){
			$("#partmenu_con ul.first").off("click");
			if(!secondSymptomFlag){
				var table = document.getElementById("table");
				while(table.hasChildNodes())
			    {
			        table.removeChild(table.firstChild);
			    }
				var tr = document.createElement("tr");
			    tr.innerHTML = '<td class="tr-border-bottom">症状：</td><td id="s'+symptom+'" class="isSelect tr-border-bottom">'+symptom+'</td>'; //向li内添加文本
			    table.appendChild(tr);
			    getSymptoms();
			    $("#optTip").html("请选择<span class='text-gradient'>最</span>不舒服的症状");
			    secondSymptomFlag = true;
			}else{
				var degree = $('#select1 option:selected').val()?$('#select1 option:selected').val():'';
				var nature = $('#select2 option:selected').val()?$('#select2 option:selected').val():'';
				var times = $('#select3 option:selected').val()?$('#select3 option:selected').val():'';
				var tp = $('#select4 option:selected').val()?$('#select4 option:selected').val():'';
				var factor = $('#select5 option:selected').val()?$('#select5 option:selected').val():'';
				var imgurl =  typeof($("#select6").val())=="undefined"?'':$("#select6").val();
				$("#optTip").html("请选择<span class='text-gradient'>最</span>不舒服的症状");
				window.location.href="./jsp/asking.jsp?ids="+ids.join(",")+"&symptom="+symptom+"&part="+onTwoPart+"&degree="+degree+"&nature="+nature+"&times="+times
										+"&tp="+tp+"&symptomsArr="+symptomsArr
										+"&usedSymptoms="+usedSymptoms.join(",")+"&usedParts="+usedParts.join(",")+"&factor="+factor+"&url="+imgurl;
			}
		}else if(symptomFlag){
			if(!twoPartFlag && !secondSymptomFlag){
				$("#"+onOnePart).find("a").html(onOnePart+"/"+onTwoPart);
				$("#partmenu_con ul.first").off("click");
				getPartSymptoms();
				$("#optTip").html("请选择<span class='text-gradient'>最</span>不舒服的症状");
				twoPartFlag = true;
			}else if(twoPartFlag && !secondSymptomFlag){
				var table = document.getElementById("table");
				while(table.hasChildNodes())
			    {
			        table.removeChild(table.firstChild);
			    }
				var tr = document.createElement("tr");
			    tr.innerHTML = '<td class="tr-border-bottom">症状：</td><td id="s'+symptom+'" class="isSelect tr-border-bottom">'+symptom+'</td>'; //向li内添加文本
			    table.appendChild(tr);
			    getSymptoms();
			    $("#optTip").html("请选择<span class='text-gradient'>最</span>不舒服的症状");
			    secondSymptomFlag = true;
			}else if(twoPartFlag && secondSymptomFlag){
				var degree = $('#select1 option:selected').val()?$('#select1 option:selected').val():'';
				var nature = $('#select2 option:selected').val()?$('#select2 option:selected').val():'';
				var times = $('#select3 option:selected').val()?$('#select3 option:selected').val():'';
				var tp = $('#select4 option:selected').val()?$('#select4 option:selected').val():'';
				var factor = $('#select5 option:selected').val()?$('#select5 option:selected').val():'';
				var imgurl = typeof($("#select6").val())=="undefined"?'':$("#select6").val();
				$("#optTip").html("请选择<span class='text-gradient'>最</span>不舒服的症状");
				window.location.href="./jsp/asking.jsp?ids="+ids.join(",")+"&symptom="+symptom+"&part="+onTwoPart+"&degree="+degree+"&nature="+nature+"&times="+times
										+"&tp="+tp+"&symptomsArr="+symptomsArr
										+"&usedSymptoms="+usedSymptoms.join(",")+"&usedParts="+usedParts.join(",")+"&factor="+factor+"&url="+imgurl;
			}
		}else{
			window.location.href="./jsp/conditionsList.jsp";
		}
	}
	
	//数组去重
	function unique(arr) {
	    var result = [], isRepeated;
	    for (var i = 0;i<arr.length;i++) {
	        isRepeated = false;
	        for (var j = 0;j<result.length;j++) {
	            if (arr[i] == result[j]) {   
	                isRepeated = true;
	                break;
	            }
	        }
	        if (!isRepeated) {
	            result.push(arr[i]);
	        }
	    }
	    return result;
	}
	
	Array.prototype.min = function() {
		var min = this[0];
		var len = this.length;
		for (var i = 1; i < len; i++){ 
			if (this[i] < min){ 
				min = this[i]; 
			} 
		} 
		return min;
	}
	//最大值
	Array.prototype.max = function() { 
		var max = this[0];
		var len = this.length; 
		for (var i = 1; i < len; i++){ 
			if (this[i] > max) { 
				max = this[i]; 
			} 
		} 
		return max;
	}

	
	function spliceSyms(ret){
		var degrees = [];
       	var medicines = [];
       	var natures = [];
       	var urls = [];
       	var timess = [];
       	var tp = [];
       	var factors = [];
		for(var i=0;i<ret.length;i++){
			if(ret[i].degree!=null && ret[i].degree!=''){
				degrees.push(ret[i].degree);
			}
			if(ret[i].medicine!=null && ret[i].medicine==''){
				medicines.push(ret[i].medicine);
			}
			if(ret[i].imgurl!=null && ret[i].imgurl!=''){
				urls.push(ret[i].imgurl);
			}
			if(ret[i].nature!=null && ret[i].nature!=''){
				natures.push(ret[i].nature);
			}
			if(ret[i].times!=null && ret[i].times!=''){
				timess.push(ret[i].times);
			}
			if(ret[i].sdown!=null && ret[i].sdown!='' ){
				tp.push(ret[i].sdown);
			}
			if(ret[i].sup!=null && ret[i].sup!=''){
				tp.push(ret[i].sup);
			}
			if(ret[i].factor!=null && ret[i].factor!=''){
				factors.push(ret[i].times);
			}
		}
		degrees = unique(degrees);
       	medicines = unique(medicines);
       	natures = unique(natures);
       	urls = unique(urls);
       	timess = unique(timess);
       	factors = unique(factors);
       	var tpMax = tp.max();
       	var tpMin = tp.min();
       	if(degrees.length>0){
       		var table = document.getElementById("table");
       		var tr = document.createElement("tr");
       		var html = '<option value="">选择程度</option>';
       		for(var i=0;i<degrees.length;i++){
       			 html += '<option value="'+degrees[i]+'">'+degrees[i]+'</option>'
       		}
       		tr.innerHTML ='<td class="tr-border-bottom">程度：</td><td class="tr-border-bottom"><select class="weui_select" id="select1" style="text-align: center;">'+html+'</select></td>';
       		table.appendChild(tr);
       	}
       	if(natures.length>0){
       		var table = document.getElementById("table");
       		var tr = document.createElement("tr");
       		var html = '<option value="">选择性质</option>';
       		for(var i=0;i<natures.length;i++){
       			 html += '<option value="'+natures[i]+'">'+natures[i]+'</option>'
       		}
       		tr.innerHTML ='<td>性质：</td><td><select class="weui_select" id="select2" style="text-align: center;">'+html+'</select></td>';
       		table.appendChild(tr);
       	}
       	if(timess.length>0){
       		var table = document.getElementById("table");
       		var tr = document.createElement("tr");
       		var html = '<option value="">选择次数</option>';
       		for(var i=0;i<timess.length;i++){
       			 html += '<option value="'+timess[i]+'">'+timess[i]+'</option>'
       		}
       		tr.innerHTML ='<td>周期：</td><td><select class="weui_select" id="select3" style="text-align: center;">'+html+'</select></td>';
       		table.appendChild(tr);
       	}
       	if(factors.length>0){
       		var table = document.getElementById("table");
       		var tr = document.createElement("tr");
       		var html = '<option value="">选择因素</option>';
       		for(var i=0;i<factors.length;i++){
       			 html += '<option value="'+factors[i]+'">'+factors[i]+'</option>'
       		}
       		tr.innerHTML ='<td>因素：</td><td><select class="weui_select" id="select5" style="text-align: center;">'+html+'</select></td>';
       		table.appendChild(tr);
       	}
       	if(urls.length>0){
      		var table = document.getElementById("table");
       		var tr = document.createElement("tr");
       		var html = '<option value="">选择图片</option>';
			for(var i=0;i<urls.length;i++){
				 curr_img_select_arr.push(urls[i]);
			}
			tr.innerHTML = '<td>图片：</td><td><input type="text" id="select6" onclick="showPic()" class="weui_select select-bor"></td>';
			table.appendChild(tr);
		}
       	if(tpMin!=tpMax){
       		var table = document.getElementById("table");
       		var tr = document.createElement("tr");
       		var html = '<option value="">选择数值</option>';
       		if(ret[0].symptom=="体温" || ret[0].symptom=="发烧" || ret[0].symptom=="低体温"){
       			for(var i=tpMin;i<tpMax;){
       				var j = Number(i).toFixed(1);
	       			html += '<option value="'+j+'">'+j+'</option>';
	       			i = i+0.1;
	       		}
       		}else{
       			for(var i=tpMin;i<tpMax;i++){
       				var j = Number(i).toFixed(0);
	       			html += '<option value="'+j+'">'+j+'</option>';
	       		}
       		}
       		tr.innerHTML ='<td>数值：</td><td><select class="weui_select" id="select4" style="text-align: center;">'+html+'</select></td>';
       		table.appendChild(tr);
       	}
	} 
	
	function getSymptoms(){
		$.ajax({
	        url: "./newIllOper/getSymptoms.spring",
	        data: {
	        	ids : ids.join(","),
	        	symptom : symptom
	        },
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
				spliceSyms(ret);
	        }
        });
	}
	
	function getPartSymptoms(){
		if(ids.length==0){
			alert("还未有疾病！");
			return;
		}
		$.ajax({
	        url: "./newIllOper/getSymptomsByPart.spring",
	        data: {
	        	ids : ids.join(","),
	        	part : onTwoPart
	        },
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	if(ret.symptoms.length==0){
	        		alert("该部位还未有症状！");
					window.location.href="./jsp/conditionsList.jsp";
	        	}else{
     			    var table = document.getElementById("table");
					while(table.hasChildNodes())
				    {
				        table.removeChild(table.firstChild);
				    }
				    for(var i=0;i<ret.symptoms.length;i++){
				    	var table = document.getElementById("table");
						var tr = document.createElement("tr");
						var sym1 = ret.symptoms[i];
						var sym2 = ret.symptoms[++i];
						if(sym2){
							tr.innerHTML = '<td id="s'+sym1+'" onclick="showsym(\''+sym1+'\')">'+sym1
											+'</td><td id="s'+sym2+'" onclick="showsym(\''+sym2+'\')">'+sym2+'</td>'; //向li内添加文本
						}else{
							tr.innerHTML = '<td id="s'+sym1+'" onclick="showsym(\''+sym1+'\')">'+sym1+'</td><td id=""></td>'; //向li内添加文本
						}
						table.appendChild(tr);
				    }
				    symptomFlag = true;
	        	}
	        }
        });
	}
	
	function getIllnessBySexAndAge(){
		if(storage.getItem("curSex")=='' || storage.getItem("curAgeFlag")==''){
			alert("请选择角色");
			return;
		}
		$.ajax({
	        url: "./newIllOper/getIllnessBySexAndAge.spring",
	        data: {
	        	sex : storage.getItem("curSex"),
	        	age : storage.getItem("curAgeFlag")
	        },
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	ids = ret.ids;
	        	sexAndAgeFlag = true;
	        }
        });
	}
	
	function queryAllPartGroups(){
		$.ajax({
	        url: "./part/queryAllPartGroups.spring",
	        data: {},
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	var temp;
	        	if(ret.rows.length>1){
	        		for(var i=0;i<ret.rows.length;i++){
	        			for(var j=0;j<ret.rows.length-1;j++){
	        				if(ret.rows[j][0].oneNum>ret.rows[j+1][0].oneNum){
			        			temp = ret.rows[j];
			        			ret.rows[j] = ret.rows[j+1];
			        			ret.rows[j+1] = temp;
			        		}
	        			}
		        	}
	        	}
				console.log(ret);
				$("#parts").html('');
				var ul = document.getElementById("parts");
				var li = document.createElement("li"); //创建li
				if(!findMod){
					li.className="isActive";
					getCommonSymp();
				}
				li.innerHTML = '<a class="text-color" herf="javascript:void();" id="common_symp">常见症状</a>'; //向li内添加文本
				ul.appendChild(li); //把li 添加到ul子节点的末尾
				
				var ul = document.getElementById("parts");
				var li = document.createElement("li"); //创建li
				if(findMod){
					li.className="isActive";
				}
				li.innerHTML = '<a class="text-color" herf="javascript:void();" id="find_symp">搜索症状</a>'; //向li内添加文本
				ul.appendChild(li); //把li 添加到ul子节点的末尾
				
				for(var i=0;i<ret.rows.length;i++){
					var ul = document.getElementById("parts");
					var li = document.createElement("li"); //创建li
					var obj;
					var twoArr = [];
					var onePart = ret.rows[i][0].onePart;
					for(var j=0;j<ret.rows[i].length;j++){
						twoArr.push(ret.rows[i][j].twoPart);	
					}
					obj = {
						onePart : onePart,
						arr: twoArr
					};
					partArr.push(obj);
					li.id=onePart;
					li.innerHTML = '<a class="text-color" herf="javascript:void();">'+onePart+'</a>'; //向li内添加文本
					ul.appendChild(li); //把li 添加到ul子节点的末尾
				}
				findMod = false;
	        }
	    });
	}
	
	function getCommonSymp(){
		$.ajax({
	        url: "./newIllOper/getCommonSymp.spring",
	        data: {},
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	if(ret && ret.length>0){
					for(var i=0;i<ret.length;i++){
						var table = document.getElementById("table");
						var tr = document.createElement("tr");
						if(i+1<ret.length){
							tr.innerHTML = '<td id="s'+ret[i]+'" onclick="showsym(\''+ret[i]+'\')">'+ret[i]
											+'</td><td id="s'+ret[i+1]+'" onclick="showsym(\''+ret[i+1]+'\')">'+ret[i+1]+'</td>'; //向li内添加文本
						}else{
							tr.innerHTML = '<td id="s'+ret[i]+'" onclick="showsym(\''+ret[i]+'\')">'+ret[i]+'</td><td id=""></td>'; //向li内添加文本
						}
						i++;
						table.appendChild(tr);
					}
				}
	        }
        });
	}
	
	//获取部位
	queryAllPartGroups();
	
	function show(part){
		$("#p"+part+"").siblings().removeClass("isSelect");
		$("#p"+part+"").parent().parent().find("tr").find("td").removeClass("isSelect");
		$("#p"+part+"").addClass("isSelect");
		onTwoPart = part;
		$("#btn").addClass("btn-select");
	}
	
	function showsym(sym){
		$("#s"+sym+"").siblings().removeClass("isSelect");
		$("#s"+sym+"").parent().parent().find("tr").find("td").removeClass("isSelect");
		$("#s"+sym+"").addClass("isSelect");
		symptom = sym;
		//本来点击症状显示
		setInterval(function(){
			if(sexAndAgeFlag){
				$("#btn").addClass("btn-select");
			}
		},100);
		$("optTip").html("请选择最不适合的病症");
	}
	
    function roleMenu(){
        var w_height = $(window).height();
        $('.theleftmenu').css('height',w_height);
        $('.theleftmenu').css('display','block');
        //   弹出边菜单
        $('.theleftmenu .bg_mark').css('display','block');
        
        $('.theleftmenu .theleftmenu_con ' ).stop().animate({ left: '0' }, 400);
        $('.cancle').click(function(){
        	  $('.theleftmenu').css('height',w_height);
            $('.theleftmenu .leftmenu_con ').stop().animate({ left: '-100%' }, 400);
            setTimeout(function(){
                $('.theleftmenu,.bg_mark').fadeOut('fast');
            },200);
        });
    }
	
	//切换角色
    function changeRole(){
    	$.ajax({
	    	url: "./user/getRoles",
   	       	type: "POST",
   	       	data : {
   	       		primaryRole : storage.getItem("primaryRole")
   	       	},
   	      	dataType: 'json',
   	       	cache: false,
   	       	success: function (ret) {
   	       		if(ret.resultCode==0){
   	       			roleMenu();
   	       			var roleHTML="";
    	        	$("#role").html("");
   	               	for(var i=0;i<ret.content.length;i++){
   	               		roleHTML+="<label class=\"weui_cell weui_check_label\" for=\"x"+(i+1)+"\">";
	  	                roleHTML+="<div class=\"weui_cell_bd weui_cell_primary\">";
	   	                roleHTML+=" <p>"+ret.content[i].userName+"</p> </div>";
	   				 	roleHTML+="<div class=\"weui_cell_ft\">";
	   				 	roleHTML+="<input type=\"radio\" class=\"weui_check\" name=\"radio100\" id=\"x"+(i+1)+"\" value="+ret.content[i].userCode+">";
	   				 	roleHTML+="<span class=\"weui_icon_checked\"></span>";
	   				 	roleHTML+="</div></label>";
   				 	}
 					$("#role").html(roleHTML);
   	       		}else{
   	       			alert(ret.msg);
   	       			window.location.href = "./jsp/login.jsp";
   	       		}
  	       	}
   	   	});
    }
    
    function showPic(){
		$("#picBox").show();
	    var im = document.getElementById("im");
	    var ims = document.createElement("div");
	    var html_img ='';
	    for(var i=0;i<curr_img_select_arr.length;i++){
	    	html_img+= '<img alt="" src="../img/'+curr_img_select_arr[i]+'" style="width:100%;margin:2px 0px" onclick="select_this_img(\''+curr_img_select_arr[i]+'\',this)"></br>';
	    }
	   	ims.innerHTML = html_img;
	   	im.appendChild(ims);
	}
	
	function IMG_OK(){
		$("#picBox").hide();
		$("#im").html('');
		$("#select6").val(select_this_imgs[0]?select_this_imgs[0]:"无");
	}
	
	var select_this_imgs = [];
	function select_this_img(t,tt){
		$("#im").find("img").removeClass("img_border");
		$(tt).addClass("img_border");
		select_this_imgs = [];
		select_this_imgs.push(t);
	}
    
    function input_symp(){
    	if(secondSymptomFlag){
    		return;
    	}
    	var input_text = $("#symp_input").val();
    	if(input_text!=null &&　input_text!=''){
    		$("#optTip").html("<请选择<span class='text-gradient'>最</span>不舒服的症状>");
    		$("#btn").addClass("btn-select");
    		findMod = true;
    		queryAllPartGroups();//重新加载部位
    		var table = document.getElementById("table");
			while(table.hasChildNodes())
		    {
		        table.removeChild(table.firstChild);
		    }
		    
		    $.ajax({
		    	url: "./newIllOper/getSympByLike",
	   	       	type: "POST",
	   	       	data : {
	   	       		sympName : input_text
	   	       	},
	   	      	dataType: 'json',
	   	       	cache: false,
	   	       	success: function (ret) {
					if(ret && ret.length>0){
						for(var i=0;i<ret.length;i++){
							var table = document.getElementById("table");
							var tr = document.createElement("tr");
							if(i+1<ret.length){
								tr.innerHTML = '<td id="s'+ret[i]+'" onclick="showsym(\''+ret[i]+'\')">'+ret[i]
												+'</td><td id="s'+ret[i+1]+'" onclick="showsym(\''+ret[i+1]+'\')">'+ret[i+1]+'</td>'; //向li内添加文本
							}else{
								tr.innerHTML = '<td id="s'+ret[i]+'" onclick="showsym(\''+ret[i]+'\')">'+ret[i]+'</td><td id=""></td>'; //向li内添加文本
							}
							i++;
							table.appendChild(tr);
						}
					}
	  	       	}
	   	   	});
		    /* $("#symp_input").val(''); */	
    	}
		findMod = true;
    }
</script>
</head>
<body >
<div>
	<form role="form" style="margin: 5px;">
  		<input class="form-control input_style" type="text" placeholder="&nbsp;&nbsp;&nbsp;请输入症状名" id="symp_input" oninput="input_symp()">
  		<span class="btn change_role" onclick="changeRole();" ><span id="my_role"></span>>></span>
  		<span class="help-block">
  		<i class="weui_icon_search" style="position: absolute;top: 12px;z-index:99;margin-left: 8px"></i>
	</form>
</div>
<div style="width:100%;height:1px;margin:0px auto;padding:0px;background-color:#efefef;overflow:hidden;"></div>
	<section class="partmenu" style="height: 627px; display: block;margin-top: 50px;width: 30%;overflow-y:hidden;">
		<span class="bg_mark" style="display: block;"></span>

		<div class="partmenu_con" id="partmenu_con" style="background-color: #fff;width:100%;text-align: center;left: 0;overflow: scroll;overflow:auto;　overflow-y:scroll;">
			<ul class="part first" id="parts" style="line-height: 2.5em">
					
			</ul>
		</div>
	</section>
	<section >
		<div class="container" style="margin-top: 50px;margin-left: 30%;padding-right:0;overflow: scroll;">
			<table style="margin-top:9px;">
				<thead id="optTip">
				</thead>
				<tbody id="table">
<!-- 					<tr>
						<td>谁谁谁</td>
						<td>谁谁谁</td>
					</tr> -->
				</tbody>
			</table>
		</div>
	</section>
	<section class="theleftmenu" style="height: 627px; display: none;">
		<span class="bg_mark" style="display: none;"></span>
		<div class="theleftmenu_con"  style="background-color: #fff;width: 90%;height:auto;margin-top: 30%;margin-left: 5%;text-align: center;">
			<p class="m_tit" style="font-size: 18px;padding-top: 5px;">请选择角色</p>
			<div class="weui_cells weui_cells_radio" id="role"></div> 
        	<a href="javascript:;" class="weui_btn weui_btn_plain_primary" style="margin: 3px;" onclick="commit();">确定</a>
		</div>
	</section>
	<div class="weui_dialog_confirm" id="picBox" style="display: none;">
	    <div class="weui_mask"></div>
	    <div class="weui_dialog" >
	    	<div style="margin:15px 0;border-bottom: 1px solid #efefef;padding-bottom:8px;">关联图片</div>
	    	<div id="im" style="height:300px; overflow:auto;"></div>
	        <div class="weui_dialog_ft">
	            <a href="javascript:;" class="weui_btn_dialog primary" onclick="IMG_OK()">确定</a>
	        </div>
	    </div>
	</div>
<footer>
	<ul>
		<li onclick="toAsk();" id="btn"><p style="margin-top: 8px !important;">选择完成</p></li>
	</ul>
</footer>
</body>
</html>
